package com.ai.module.suno.service.impl;

import com.ai.module.chat.common.base.ThreadLocalContext;
import com.ai.module.suno.domain.entity.UserSunoRecordEntity;
import com.ai.module.suno.domain.req.SunoReq;
import com.ai.module.suno.domain.vo.SunoRecordVo;
import com.ai.module.suno.domain.vo.UserSunoVo;
import com.ai.module.suno.mapper.UserSunoRecordMapper;
import com.ai.module.suno.service.SunoRecordService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: heJinQin
 * @create: 2024-04-27 12:13
 * @description:
 **/
@Slf4j
@Service
public class SunoRecordServiceImpl extends ServiceImpl<UserSunoRecordMapper, UserSunoRecordEntity> implements SunoRecordService {

    @Autowired
    private UserSunoRecordMapper userSunoRecordMapper;

    @Override
    public IPage<UserSunoVo> sunoRecord(SunoReq page) {
        String userId = ThreadLocalContext.getUserId();
        Page<SunoRecordVo> voPage = new Page<>(page.getPage(),page.getSize());
        return  userSunoRecordMapper.findUserRecord(voPage,userId,page.getRobotId());

    }

    @Override
    public SunoRecordVo sunoDetail(String sunoId) {
        return  userSunoRecordMapper.sunoDetail(sunoId);
    }
}
